FROM maven:3-jdk-8-alpine as builder
WORKDIR /app
COPY settings.xml /usr/share/maven/ref/repository/settings.xml
COPY pom.xml .
COPY roll-gateway/pom.xml roll-gateway/
COPY roll-core/pom.xml roll-core/
COPY roll-common/pom.xml roll-common/
COPY roll-passport/pom.xml roll-passport/
COPY roll-upms/pom.xml roll-upms/
COPY roll-empty/pom.xml roll-empty/
COPY roll-wms/pom.xml roll-wms/
COPY roll-process/pom.xml roll-process/
COPY roll-report/pom.xml roll-report/
COPY roll-opcua/pom.xml roll-opcua/

RUN mvn -B -s /usr/share/maven/ref/repository/settings.xml dependency:resolve-plugins dependency:resolve clean package

COPY ./ ./

RUN mvn -B -s /usr/share/maven/ref/repository/settings.xml  -Dmaven.test.skip=true -Ptest  clean package

FROM anapsix/alpine-java:8_server-jre_unlimited
LABEL mantainer=shihairong@zimonet.com
RUN apk add tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ENV TZ=Asia/Shanghai
WORKDIR /app
COPY --from=builder  /app/roll-gateway/target/*.jar  /app/app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"] 